package day20171007;



import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

import java.io.FileOutputStream;
import java.io.OutputStream;
import java.rmi.server.ExportException;

/**
 * Created by 14394 on 2017/10/7.
 */
public class TestJxl {
    public static void main(String[] args) {
        String[] title={"姓名","学号"};
        try{
            long start=System.currentTimeMillis();
            String filePath="D:\\dev\\Jxl.xls";
            WritableWorkbook wwb;
            OutputStream os=new FileOutputStream(filePath);
            wwb= Workbook.createWorkbook(os);
            WritableSheet sheet=wwb.createSheet("学生信息",0);
            Label label;
            for (int i=0;i<title.length;i++){
                label =new Label(i,0,title[i]);
                sheet.addCell(label);
            }
           // jxl.write.Number number=new Number(1,1,1606102009);
            //sheet.addCell(number);
            label=new Label(0,1,"陈开海");
            sheet.addCell(label);
            sheet.mergeCells(0,2,1,2);
            label=new Label(0,2,"合并了两个单元格");
            sheet.addCell(label);

            wwb.write();
            wwb.close();
            long end=System.currentTimeMillis();
            System.out.println("--完成该操作共用的时间是："+(end-start)/1000);
        }catch (Exception e){
            System.out.println("--出现异常--");
            e.printStackTrace();
        }
    }
}
